package net.area80.components
{
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import org.osflash.signals.Signal;
	
	public class UIListItem extends Sprite
	{
		public var SIGNAL_MOUSE_DOWN:Signal = new Signal(UIListItem);
		
		public var hit_mc:Sprite;
		protected var mainList:Sprite;
		
		public function UIListItem()
		{
			if(getChildByName("hit_mc")) { 
				hit_mc = getChildByName("hit_mc") as Sprite;
			} else {
				hit_mc = this;
			}
			
			super();
			
		}
		public function getSnapshot ():BitmapData {
			var bmp:BitmapData = new BitmapData(this.width,this.height,true,0x00000000);
			bmp.draw(this,null,null,null,null,true);
			return bmp;
		}
		internal function init (mainList:Sprite):void {
			this.mainList = mainList;
			initHitClip();
		}
		protected function initHitClip ():void {
			hit_mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
		}
		protected function mouseDownHandler (e:MouseEvent):void {
			dispatchMouseDownSignal();
		}
		protected function dispatchMouseDownSignal ():void {
			SIGNAL_MOUSE_DOWN.dispatch(this);
		}

	}
}